<?php

function tree($directory)
{
    $mydir = dir($directory);
    echo "<ul>\n";
    while($file = $mydir->read())
    {
        if((is_dir("$directory/$file")) AND ($file!=".") AND ($file!=".."))
        {
            echo "<li><font color=\"#ff00cc\"><b>$file</b></font></li>\n";
            tree("$directory/$file");
        }
        else
        echo "<li>$file</li>\n";
    }
    echo "</ul>\n";
    $mydir->close();
}

tree("./nowamagic");


    
    
$a=scandir('test');
$b=array();
foreach($a as $k=>$v){
    if($v=='.'||$v=='..') continue;
    if(pathinfo($v, PATHINFO_EXTENSION)!='txt') continue;
    $b[$v]=filemtime('test/'.$v);
}
asort($b);
print_r(array_keys($b));